﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Documents.Common.Models.Lite;

namespace Documents.Repository.Helpers
{
    /// <summary>
    /// Static Class that converts different model representations into their Lite (POCO)
    /// versions that are the actual objects returned in XML
    /// </summary>
    public static class ObjectHelper
    {
        internal static Document Get(Documents.Repository.BusinessObjects.Document d)
        {
            return new Document
            {
                DocumentAuthor = d.DocumentAuthor,
                DocumentCreationDate = d.DocumentCreationDate,
                DocumentData = null,
                DocumentID = d.DocumentID,
                DocumentTitle = d.DocumentTitle,
                DocumentTypeCode = d.DocumentTypeCode,
                Revoked = d.Revoked
            };
        }

        internal static Document Get(Documents.Repository.BusinessObjects.vwHeadDocument d)
        {
            return new Document
            {
                DocumentAuthor = d.DocumentAuthor,
                DocumentCreationDate = d.DocumentCreationDate,
                DocumentData = null,
                DocumentID = d.DocumentID,
                DocumentTitle = d.DocumentTitle,
                DocumentTypeCode = d.DocumentTypeCode,
                Revoked = d.Revoked
            };
        }

        internal static DocumentType Get(Documents.Repository.BusinessObjects.DocumentType dt)
        {
            return new DocumentType
            {
                DocumentTypeCode = dt.DocumentTypeCode,
                DocumentTypeName = dt.DocumentTypeName
            };
        }
    }
}
